package cn.ddiancan.auth.service.token;

import java.util.Map;

import cn.ddiancan.auth.constant.RequestSourceEnum;
import lombok.Getter;
import org.springframework.security.core.Authentication;
import org.springframework.security.oauth2.core.AuthorizationGrantType;
import org.springframework.util.Assert;

@Getter
public class XddAuth2UserCodeAuthenticationToken extends XddAuth2GrantAuthenticationToken {

    private final String userCode;

    public XddAuth2UserCodeAuthenticationToken(String requestType, String userCode, Authentication clientPrincipal,
        Map<String, Object> additionalParameters) {
        super(AuthorizationGrantType.DEVICE_CODE, clientPrincipal, additionalParameters);
        Assert.hasText(userCode, "userCode cannot be empty");
        this.userCode = userCode;
        this.requestSource = RequestSourceEnum.USER_CODE;
        this.requestType = requestType;
    }
}
